package com.github.shiqiyue.learn.elasticsearch;

import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;

import java.io.IOException;

/***
 * 添加-测试
 * @author wenyao.wu
 * @date 2019/1/17
 */
public class AddTest {

    public static void main(String[] args) throws IOException {
        RestHighLevelClient client = EsUtil.getClient();
        CreateIndexRequest request = new CreateIndexRequest("app");
        //类型定义
        //类型映射，需要的是一个JSON字符串
        request.mapping("tweet2",
                "  {\n" +
                        "    \"tweet\": {\n" +
                        "      \"properties\": {\n" +
                        "        \"message\": {\n" +
                        "          \"type\": \"text\"\n" +
                        "        }\n" +
                        "      }\n" +
                        "    }\n" +
                        "  }",
                XContentType.JSON);
        CreateIndexResponse createIndexResponse = client.indices().create(request);
    }


}
